package com.byit.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.byit.domain.AppCharacteristic;
import com.byit.msg.MessageResult;
import com.byit.service.IAppCharacteristicService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 特色江油 前端控制器
 *
 * @author tjm
 * @date 2019年1月9日
 */
@RestController
@RequestMapping("/app/characteristic")
public class AppCharacteristicController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private IAppCharacteristicService appCharacteristicService;

    /**
     * app获取政民互动
     */
    @GetMapping("/list")
    public Object list() {
        EntityWrapper<AppCharacteristic> wrapper = new EntityWrapper<>();
        wrapper.setSqlSelect("id,content,url");
        wrapper.eq("type", "T_M_0");
        wrapper.eq("is_del", 0);
        wrapper.orderBy("by_order", false);
        List<Map<String, Object>> mapList = appCharacteristicService.selectMaps(wrapper);
        return MessageResult.warpper("000", mapList, "获取政民互动成功");
    }

    @PostMapping("/click")
    public void click(@RequestParam(name = "id") Long id) {
        appCharacteristicService.addCountOne(id);
    }

}
